//C17:17.10:tree.h -- binary search tree.
#ifndef _TREE_H_
#define _TREE_H_
#include <stdbool.h>

typedef struct item
{
    char petname[20];
    char petkind[20]; 
} Item;

#define MAXITEMS  10

typedef struct node
{
    Item item;
    struct node *left;
    struct node *right;
} Node;

typedef struct tree
{
    Node *root;
    int size;
} Tree;

/*Initial tree*/
void InitializeTree(Tree *ptree);

/*Tree is empty*/
bool TreeIsEmpty(const Tree *ptree);

/*Tree is full*/
bool TreeIsFull(const Tree *ptree);

/*Tree item count*/
int TreeItemCount(const Tree *ptree);

/*Add item*/
bool AddItem(const Item *pi, Tree *ptree);

/*in tree*/
bool InTree(const Item *pi, const Tree *ptree);

/*Delete item*/
bool DeleteItem(const Item *pi, Tree *ptree);

void DeleteAll(Tree *ptree);

/*travel tree*/
void Traverse(const Tree *ptree, void(*pfun)(Item item));
#endif